import 'package:flutter/material.dart';

import '../pages/tabs.dart';
import '../pages/form.dart';
import '../pages/search.dart';
import '../pages/product.dart';
import '../pages/product-info.dart';
import '../pages/user/login.dart';
import '../pages/user/register1.dart';
import '../pages/user/register2.dart';
import '../pages/user/register3.dart';

//配置路由
final routes = {
  '/': (context, {arguments}) => Tabs(),
  '/form': (context, {arguments}) => FormPage(),
  '/search': (context, {arguments}) => SearchPage(arguments: arguments),
  '/product': (context, {arguments}) => ProductPage(),
  '/productInfo': (context, {arguments}) => ProductInfoPage(arguments: arguments),
  '/login': (context, {arguments}) => LoginPage(),
  '/register': (context, {arguments}) => RegisterPage(),
  '/registerNext': (context, {arguments}) => RegisterNextPage(),
  '/registerThird': (context, {arguments}) => RegisterThirdPage(),
};

//固定写法
var onGenerateRoute = (RouteSettings settings){
  // 统一处理
  final String name = settings.name; 
  final Function pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    }else{
        final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context));
        return route;
    }
  }
};